import fetch from '@/utils/request';

const API_DISTRIBUTION_URL = '/api/user/sale';
/**
 * 分销API对象
 * @module DistributionApi
 */
const DistributionApi = {
	/**
	 * @function recruit
	 * @description 检查申请信息
	 */
	apply: () => fetch.request({
		url: `${API_DISTRIBUTION_URL}/saler/apply`,
		method: 'GET',
	}),
	/**
	 * @function recruit
	 * @description 得到分销招幕信息
	 */
	recruit: () => fetch.request({
		url: `${API_DISTRIBUTION_URL}/recruit/get`,
		method: 'GET',
	}),
	/**
	 * @function recruit
	 * @description 申请成为分销员
	 * @param  {Object} salerApply 分销员对象
	 */
	save: (salerApply) => fetch.request({
		url: `${API_DISTRIBUTION_URL}/saler/apply`,
		method: 'POST',
		data: {
			apply: salerApply
		}
	}),
	/**
	 * @function get
	 * @description 得到分销人员对象
	 */
	get: () => fetch.request({
		url: `${API_DISTRIBUTION_URL}/saler/get`,
		method: 'POST',
	}),
	/**
	 * @function getDistributionGrade
	 * @description 得到分销等级
	 */
	getDistributionGrade: () => fetch.request({
		url: `${API_DISTRIBUTION_URL}/setting/get`,
		method: 'GET',
	}),
	/**
	 * @function oneLevelSalers
	 * @description 查询下级分销员（一级分销商）
	 * @param  {Object} query 查询参数对象
	 * @param  {Object} param 分页参数对象
	 */
	oneLevelSalers: (query, param) => fetch.request({
		url: `${API_DISTRIBUTION_URL}/saler/salers`,
		method: 'POST',
		data: {
			query: {
				queryType: '1'
			},
			param: param
		},
	}),
	/**
	 * @function twoLevelSalers
	 * @description 查询下级分销员（二级分销商）
	 * @param  {Object} query 查询参数对象
	 * @param  {Object} param 分页参数对象
	 */
	twoLevelSalers: (query, param) => fetch.request({
		url: `${API_DISTRIBUTION_URL}/saler/salers`,
		method: 'POST',
		data: {
			query: {
				queryType: '2'
			},
			param: param
		},
	}),
	/**
	 * @function customers
	 * @description 查询我的客户（20天顾客）
	 * @param  {Object} query 查询参数对象
	 * @param  {Object} param 分页参数对象
	 */
	customers: (query, param) => fetch.request({
		url: `${API_DISTRIBUTION_URL}/saler/customers`,
		method: 'POST',
		data: {
			query: {
				queryType: '1'
			},
			param: param
		},
	}),
	/**
	 * @function perpetualCustomers
	 * @description 查询我的客户（永久顾客）
	 * @param  {Object} query 查询参数对象
	 * @param  {Object} param 分页参数对象
	 */
	perpetualCustomers: (query, param) => fetch.request({
		url: `${API_DISTRIBUTION_URL}/saler/customers`,
		method: 'POST',
		data: {
			query: {
				queryType: '2'
			},
			param: param
		},
	})
};
export default DistributionApi;